package cn.sczhyt.modules.app.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import cn.sczhyt.modules.app.annotation.Login;
import cn.sczhyt.modules.app.annotation.LoginUser;
import cn.sczhyt.modules.app.entity.UserEntity;
import cn.sczhyt.modules.szhy.entity.VO.MeetingNoticeVO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import cn.sczhyt.modules.szhy.entity.MeetingNoticeReceiveEntity;
import cn.sczhyt.modules.szhy.service.MeetingNoticeReceiveService;
import cn.sczhyt.common.utils.PageUtils;
import cn.sczhyt.common.utils.R;


/**
 * 通知接收表
 *
 * @author luojialin
 * @email 78357966@qq.com
 * @date 2021-04-02 10:15:15
 */
@Api("App消息接收模块")
@RestController
@RequestMapping("app/meetingnoticereceive")
public class AppMeetingNoticeReceiveController {
    @Autowired
    private MeetingNoticeReceiveService meetingNoticeReceiveService;

    /**
     * 查询自己消息的列表
     */
    @Login
    @ApiOperation("查询自己消息的列表")
    @GetMapping("/list")
    public R list(@LoginUser UserEntity user){


        List<MeetingNoticeVO> list = meetingNoticeReceiveService.getList(user.getUserId());

        return R.ok().put("data", list);
    }
    /**
     * 消息已读确认
     */
    @Login
    @ApiOperation("查询自己消息的列表")
    @GetMapping("/state/{noticeId}")
    public R state(@LoginUser UserEntity user,@PathVariable("noticeId") String noticeId){

        meetingNoticeReceiveService.update(new UpdateWrapper<MeetingNoticeReceiveEntity>()
                .eq("notice_id",noticeId)
                .eq("notice_receiver_id",user.getUserId())
                .set("notice_receive_status",true));

        return R.ok();
    }






}
